// $ANTLR 3.0.1 Roller.g 2008-04-03 19:34:48

package com.braincasedesigns.roller.parser.generated;
import com.braincasedesigns.roller.parser.model.*;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class RollerParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "LPAREN", "RPAREN", "WS", "SEMI", "NEWLINE", "DEE", "PLUS", "MINUS", "MULTIPLY", "NON_ZERO", "'F'", "'f'", "'%'"
    };
    public static final int SEMI=7;
    public static final int MINUS=11;
    public static final int EOF=-1;
    public static final int WS=6;
    public static final int NON_ZERO=13;
    public static final int RPAREN=5;
    public static final int LPAREN=4;
    public static final int PLUS=10;
    public static final int DEE=9;
    public static final int MULTIPLY=12;
    public static final int NEWLINE=8;

        public RollerParser(TokenStream input) {
            super(input);
        }
        

    public String[] getTokenNames() { return tokenNames; }
    public String getGrammarFileName() { return "Roller.g"; }



    // $ANTLR start rolls
    // Roller.g:12:1: rolls returns [List<RollDescription> rolls = new ArrayList<RollDescription>()] : (d= repeatedDieRoll ( seperator )* )* EOF ;
    public final List<RollDescription> rolls() throws RecognitionException {
        List<RollDescription> rolls =  new ArrayList<RollDescription>();

        RollDescription d = null;


        try {
            // Roller.g:13:2: ( (d= repeatedDieRoll ( seperator )* )* EOF )
            // Roller.g:13:5: (d= repeatedDieRoll ( seperator )* )* EOF
            {
            // Roller.g:13:5: (d= repeatedDieRoll ( seperator )* )*
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==NON_ZERO) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // Roller.g:13:6: d= repeatedDieRoll ( seperator )*
            	    {
            	    pushFollow(FOLLOW_repeatedDieRoll_in_rolls37);
            	    d=repeatedDieRoll();
            	    _fsp--;

            	    rolls.add(d);
            	    // Roller.g:13:40: ( seperator )*
            	    loop1:
            	    do {
            	        int alt1=2;
            	        int LA1_0 = input.LA(1);

            	        if ( ((LA1_0>=WS && LA1_0<=NEWLINE)) ) {
            	            alt1=1;
            	        }


            	        switch (alt1) {
            	    	case 1 :
            	    	    // Roller.g:13:40: seperator
            	    	    {
            	    	    pushFollow(FOLLOW_seperator_in_rolls40);
            	    	    seperator();
            	    	    _fsp--;


            	    	    }
            	    	    break;

            	    	default :
            	    	    break loop1;
            	        }
            	    } while (true);


            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);

            match(input,EOF,FOLLOW_EOF_in_rolls45); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return rolls;
    }
    // $ANTLR end rolls


    // $ANTLR start repeatedDieRoll
    // Roller.g:16:1: repeatedDieRoll returns [RollDescription roll = new RollDescription()] : ( (rep= number LPAREN ) rd= dieRoll ( RPAREN ) | d= dieRoll );
    public final RollDescription repeatedDieRoll() throws RecognitionException {
        RollDescription roll =  new RollDescription();

        int rep = 0;

        RollDescription rd = null;

        RollDescription d = null;


        try {
            // Roller.g:16:71: ( (rep= number LPAREN ) rd= dieRoll ( RPAREN ) | d= dieRoll )
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==NON_ZERO) ) {
                int LA3_1 = input.LA(2);

                if ( (LA3_1==DEE) ) {
                    alt3=2;
                }
                else if ( (LA3_1==LPAREN) ) {
                    alt3=1;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("16:1: repeatedDieRoll returns [RollDescription roll = new RollDescription()] : ( (rep= number LPAREN ) rd= dieRoll ( RPAREN ) | d= dieRoll );", 3, 1, input);

                    throw nvae;
                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("16:1: repeatedDieRoll returns [RollDescription roll = new RollDescription()] : ( (rep= number LPAREN ) rd= dieRoll ( RPAREN ) | d= dieRoll );", 3, 0, input);

                throw nvae;
            }
            switch (alt3) {
                case 1 :
                    // Roller.g:17:2: (rep= number LPAREN ) rd= dieRoll ( RPAREN )
                    {
                    // Roller.g:17:2: (rep= number LPAREN )
                    // Roller.g:17:4: rep= number LPAREN
                    {
                    pushFollow(FOLLOW_number_in_repeatedDieRoll67);
                    rep=number();
                    _fsp--;

                    match(input,LPAREN,FOLLOW_LPAREN_in_repeatedDieRoll69); 

                    }

                    pushFollow(FOLLOW_dieRoll_in_repeatedDieRoll74);
                    rd=dieRoll();
                    _fsp--;

                     roll = rd; roll.setRepeat(rep);
                    // Roller.g:17:71: ( RPAREN )
                    // Roller.g:17:72: RPAREN
                    {
                    match(input,RPAREN,FOLLOW_RPAREN_in_repeatedDieRoll79); 

                    }


                    }
                    break;
                case 2 :
                    // Roller.g:19:6: d= dieRoll
                    {
                    pushFollow(FOLLOW_dieRoll_in_repeatedDieRoll93);
                    d=dieRoll();
                    _fsp--;

                    roll = d;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return roll;
    }
    // $ANTLR end repeatedDieRoll


    // $ANTLR start dieRoll
    // Roller.g:23:1: dieRoll returns [RollDescription roll = new RollDescription()] : num= number face= die (mod= modifier )* ;
    public final RollDescription dieRoll() throws RecognitionException {
        RollDescription roll =  new RollDescription();

        int num = 0;

        String face = null;

        Modifier mod = null;


        try {
            // Roller.g:23:63: (num= number face= die (mod= modifier )* )
            // Roller.g:24:2: num= number face= die (mod= modifier )*
            {
            pushFollow(FOLLOW_number_in_dieRoll118);
            num=number();
            _fsp--;

            roll.setNumberOfDice(num);
            pushFollow(FOLLOW_die_in_dieRoll124);
            face=die();
            _fsp--;

            roll.setFaces(face);
            // Roller.g:24:79: (mod= modifier )*
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( ((LA4_0>=PLUS && LA4_0<=MULTIPLY)) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // Roller.g:24:79: mod= modifier
            	    {
            	    pushFollow(FOLLOW_modifier_in_dieRoll130);
            	    mod=modifier();
            	    _fsp--;


            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);

            roll.setModifier(mod);

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return roll;
    }
    // $ANTLR end dieRoll


    // $ANTLR start seperator
    // Roller.g:27:1: seperator : ( WS )* ( SEMI | NEWLINE ) ;
    public final void seperator() throws RecognitionException {
        try {
            // Roller.g:28:2: ( ( WS )* ( SEMI | NEWLINE ) )
            // Roller.g:28:4: ( WS )* ( SEMI | NEWLINE )
            {
            // Roller.g:28:4: ( WS )*
            loop5:
            do {
                int alt5=2;
                int LA5_0 = input.LA(1);

                if ( (LA5_0==WS) ) {
                    alt5=1;
                }


                switch (alt5) {
            	case 1 :
            	    // Roller.g:28:4: WS
            	    {
            	    match(input,WS,FOLLOW_WS_in_seperator144); 

            	    }
            	    break;

            	default :
            	    break loop5;
                }
            } while (true);

            if ( (input.LA(1)>=SEMI && input.LA(1)<=NEWLINE) ) {
                input.consume();
                errorRecovery=false;
            }
            else {
                MismatchedSetException mse =
                    new MismatchedSetException(null,input);
                recoverFromMismatchedSet(input,mse,FOLLOW_set_in_seperator147);    throw mse;
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end seperator


    // $ANTLR start die
    // Roller.g:32:1: die returns [String faces = null] : DEE (val= number | s= facesString ) ;
    public final String die() throws RecognitionException {
        String faces =  null;

        int val = 0;

        String s = null;


        try {
            // Roller.g:32:34: ( DEE (val= number | s= facesString ) )
            // Roller.g:32:36: DEE (val= number | s= facesString )
            {
            match(input,DEE,FOLLOW_DEE_in_die164); 
            // Roller.g:32:40: (val= number | s= facesString )
            int alt6=2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0==NON_ZERO) ) {
                alt6=1;
            }
            else if ( ((LA6_0>=14 && LA6_0<=16)) ) {
                alt6=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("32:40: (val= number | s= facesString )", 6, 0, input);

                throw nvae;
            }
            switch (alt6) {
                case 1 :
                    // Roller.g:32:42: val= number
                    {
                    pushFollow(FOLLOW_number_in_die170);
                    val=number();
                    _fsp--;

                    faces =String.valueOf(val);

                    }
                    break;
                case 2 :
                    // Roller.g:32:86: s= facesString
                    {
                    pushFollow(FOLLOW_facesString_in_die178);
                    s=facesString();
                    _fsp--;

                    faces = s;

                    }
                    break;

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return faces;
    }
    // $ANTLR end die


    // $ANTLR start facesString
    // Roller.g:34:1: facesString returns [String value = null] : val= ( 'F' | 'f' | '%' ) ;
    public final String facesString() throws RecognitionException {
        String value =  null;

        Token val=null;

        try {
            // Roller.g:35:2: (val= ( 'F' | 'f' | '%' ) )
            // Roller.g:35:4: val= ( 'F' | 'f' | '%' )
            {
            val=(Token)input.LT(1);
            if ( (input.LA(1)>=14 && input.LA(1)<=16) ) {
                input.consume();
                errorRecovery=false;
            }
            else {
                MismatchedSetException mse =
                    new MismatchedSetException(null,input);
                recoverFromMismatchedSet(input,mse,FOLLOW_set_in_facesString200);    throw mse;
            }

            value =val.getText();

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return value;
    }
    // $ANTLR end facesString


    // $ANTLR start modifier
    // Roller.g:38:1: modifier returns [Modifier mod = null] : op= operator num= number ;
    public final Modifier modifier() throws RecognitionException {
        Modifier mod =  null;

        String op = null;

        int num = 0;


        try {
            // Roller.g:38:39: (op= operator num= number )
            // Roller.g:39:1: op= operator num= number
            {
            pushFollow(FOLLOW_operator_in_modifier222);
            op=operator();
            _fsp--;

            pushFollow(FOLLOW_number_in_modifier226);
            num=number();
            _fsp--;

             mod = new Modifier(op, num);

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return mod;
    }
    // $ANTLR end modifier


    // $ANTLR start operator
    // Roller.g:44:1: operator returns [String value= null] : ( PLUS | MINUS | MULTIPLY ) ;
    public final String operator() throws RecognitionException {
        String value =  null;

        Token PLUS1=null;
        Token MINUS2=null;
        Token MULTIPLY3=null;

        try {
            // Roller.g:44:38: ( ( PLUS | MINUS | MULTIPLY ) )
            // Roller.g:45:2: ( PLUS | MINUS | MULTIPLY )
            {
            // Roller.g:45:2: ( PLUS | MINUS | MULTIPLY )
            int alt7=3;
            switch ( input.LA(1) ) {
            case PLUS:
                {
                alt7=1;
                }
                break;
            case MINUS:
                {
                alt7=2;
                }
                break;
            case MULTIPLY:
                {
                alt7=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("45:2: ( PLUS | MINUS | MULTIPLY )", 7, 0, input);

                throw nvae;
            }

            switch (alt7) {
                case 1 :
                    // Roller.g:46:2: PLUS
                    {
                    PLUS1=(Token)input.LT(1);
                    match(input,PLUS,FOLLOW_PLUS_in_operator244); 
                    value =PLUS1.getText();

                    }
                    break;
                case 2 :
                    // Roller.g:47:2: MINUS
                    {
                    MINUS2=(Token)input.LT(1);
                    match(input,MINUS,FOLLOW_MINUS_in_operator251); 
                    value =MINUS2.getText();

                    }
                    break;
                case 3 :
                    // Roller.g:48:2: MULTIPLY
                    {
                    MULTIPLY3=(Token)input.LT(1);
                    match(input,MULTIPLY,FOLLOW_MULTIPLY_in_operator258); 
                    value =MULTIPLY3.getText();

                    }
                    break;

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return value;
    }
    // $ANTLR end operator


    // $ANTLR start number
    // Roller.g:51:1: number returns [int value] : NON_ZERO ;
    public final int number() throws RecognitionException {
        int value = 0;

        Token NON_ZERO4=null;

        try {
            // Roller.g:52:1: ( NON_ZERO )
            // Roller.g:52:3: NON_ZERO
            {
            NON_ZERO4=(Token)input.LT(1);
            match(input,NON_ZERO,FOLLOW_NON_ZERO_in_number275); 
            value = Integer.parseInt(NON_ZERO4.getText());

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return value;
    }
    // $ANTLR end number


 

    public static final BitSet FOLLOW_repeatedDieRoll_in_rolls37 = new BitSet(new long[]{0x00000000000021C0L});
    public static final BitSet FOLLOW_seperator_in_rolls40 = new BitSet(new long[]{0x00000000000021C0L});
    public static final BitSet FOLLOW_EOF_in_rolls45 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_number_in_repeatedDieRoll67 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_LPAREN_in_repeatedDieRoll69 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_dieRoll_in_repeatedDieRoll74 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_RPAREN_in_repeatedDieRoll79 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_dieRoll_in_repeatedDieRoll93 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_number_in_dieRoll118 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_die_in_dieRoll124 = new BitSet(new long[]{0x0000000000001C02L});
    public static final BitSet FOLLOW_modifier_in_dieRoll130 = new BitSet(new long[]{0x0000000000001C02L});
    public static final BitSet FOLLOW_WS_in_seperator144 = new BitSet(new long[]{0x00000000000001C0L});
    public static final BitSet FOLLOW_set_in_seperator147 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DEE_in_die164 = new BitSet(new long[]{0x000000000001E000L});
    public static final BitSet FOLLOW_number_in_die170 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_facesString_in_die178 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_facesString200 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_operator_in_modifier222 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_number_in_modifier226 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_PLUS_in_operator244 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_MINUS_in_operator251 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_MULTIPLY_in_operator258 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_NON_ZERO_in_number275 = new BitSet(new long[]{0x0000000000000002L});

}